package com.platform.module.common.redis.lock;

import com.platform.module.common.base.CodeEnum;

import java.lang.annotation.*;

@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface RedisLock {
    String key() default "";

    /**
     * 特定参数识别，默认取第0个下标
     */
    int[] lockFiled() default {0};

    /**
     * 是否取特定参数识别
     */
    boolean isLockFiled() default false;

    CodeEnum codeEnum() default CodeEnum.访问频繁;

//    String msg() default "Access speed is too fast!";

    long keepMills() default 3000L;

    LockFailAction action() default LockFailAction.GIVE_UP;

    long sleepMills() default 200L;

    int retryTimes() default 3;

    LockScope scope() default LockScope.OWN;

    UnLockMode unlockMode() default UnLockMode.AUTO;

    enum LockFailAction {
        GIVE_UP, RETRY
    }

    enum LockScope {
        OWN, ALL
    }

    enum UnLockMode {
        AUTO, MANUAL, TIMEOUT
    }
}
